<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>惠农网 - 商品管理</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/my.css" />
</head>
<body>
<div class="container">
    <%@include file="common/header.jsp"%>
    <div class="row">
        <div class="col-2">
            <%@include file="common/left.jsp"%>
        </div>
        <div class="col-10">


            <table class="table table-striped">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>商品名称</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>

                <c:forEach items="${productList}" var="product">
                    <tr>
                        <td class="align-middle">${product.epId}</td>
                        <td>
                            <img src="../images/product/${product.epFileName}" />
                                ${product.epName}
                        </td>
                        <td class="align-middle">
                            <a href="${pageContext.request.contextPath}/product/to_edit?epId=${product.epId}">修改</a>
                            <a href="javascript:Delete('${pageContext.request.contextPath}/product/delete?id=${product.epId}');">删除</a>
                        </td>
                    </tr>
                </c:forEach>

                </tbody>
            </table>

            <%--分页--%>
            <div class="row float-right">
                <nav aria-label="Page navigation example" class="float-right">
                    <ul class="pagination">
                        <li class="page-item">
                            <a class="page-link" href="${pageContext.request.contextPath}/product/list?page=${currPage>1?currPage-1:1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                                <span class="sr-only">Previous</span>
                            </a>
                        </li>
                        <c:forEach var="i" begin="${currPage>3?currPage-3:1}" end="${(totalPage-currPage)>3?currPage+3:totalPage}" step="1">
                            <li <c:if test="${i==currPage}"> class="page-item active" </c:if> <c:if test="${i!=currPage}"> class="page-item" </c:if>>
                                <a class="page-link" href="${pageContext.request.contextPath}/product/list?page=${i}">${i}</a>
                            </li>
                        </c:forEach>
                        <li class="page-item">
                            <a class="page-link" href="${pageContext.request.contextPath}/product/list?page=${currPage<totalPage?currPage+1:totalPage}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                                <span class="sr-only">Next</span>
                            </a>
                        </li>
                        <li style="line-height: 38px" class="align-middle">共${totalPage}页</li>
                    </ul>
                </nav>
            </div>


        </div>
    </div>
    <div class="row text-center">
        <%@include file="common/footer.jsp"%>
    </div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/popper.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/bootstrap.min.js"></script>
</body>
<script>
    function Delete(url)
    {
        if(confirm("确定删除吗？")){
            location.href = url;
        }
    }
</script>
</html>
